def diagAnalysis(fName):
    
    fin = open('results/%s.txt'%fName, 'r')
    numWarnings = 0
    numTracks = 0
    numTorReps = 0
    numTorMatches = 0

    lines = fin.readlines()
    unMatchedIndices = []

    curIndex = 0
    curTracks = 0
    curTorReps = 0
    curTorMatches = 0
    
    i = 0
    while i < len(lines):
        
        line = lines[i]
        if 'index' in line:
            lp = line.split(' ')
            curIndex = int(lp[1].strip(':'))
            curTracks = 0
            curTorReps = 0
            curTorMatches = 0
            numWarnings += 1

        if 'vortTracks' in line:
            lp = line.split(' ')
            curTorReps = int(lp[2].strip())
            curTracks = int(lp[0].strip())
            
            numTracks += curTracks
            numTorReps += curTorReps
            
        if 'tornado matches' in line:
            lp = line.split(' ')
            curTorMatches = int(lp[0])
            numTorMatches += curTorMatches
            if curTorMatches == 0 and curTorReps > 0:
                unMatchedIndices.append(curIndex)
        i += 1
                

    print 'num warnings = %d'%numWarnings
    print 'vortTracks = %d, tor reps = %d, tor matches = %d'%(numTracks,
                                                              numTorReps,
                                                              numTorMatches)
    print 'torRep to torMatch ratio: %.2f'%(float(numTorMatches)/numTorReps)
    for i in unMatchedIndices:
        print i
diagAnalysis('2013-05-14-01-56-00-labels-diag')
